<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>发起任务</title>

    <link rel="stylesheet" href="../lib/css/style.css">
    <link rel="stylesheet" href="./ueditor.css">

    <script src="../lib/jquery/jquery.js"></script>
    <!--    <script src="../../../static/htmljs/utils.js"></script>-->
    <link rel="stylesheet" href="../lib/font/css/font-awesome.min.css">

    <style>
        .needs-discussion:not(.djs-connection) .djs-visual > :nth-child(1) {
            stroke: rgba(66, 180, 21, 0.7) !important; /* color elements as red */
        }

        .diagram-note {
            background-color: rgba(66, 180, 21, 0.7);
            color: White;
            border-radius: 5px;
            font-family: Arial;
            font-size: 12px;
            padding: 5px;
            min-height: 16px;
            width: 50px;
            text-align: center;
        }

        .new_edit_left_title_span {
            line-height: 50px;
            font-weight: 900;
            font-weight: bold;
            font-size: 18px;
            color: #0e86fe;
        }

        #canvas {
            width: 100%;
            height: 800px;
        }

        #phead {
            list-style: none;
            overflow: hidden;
            margin: 0;
            padding: 0;
            border-bottom: 1px solid #ddd;
            margin-bottom: 10px;
        }

        #phead li {
            padding-left: 15px;
            padding-right: 15px;
            float: left;
            cursor: pointer;
            font-size: 13px;
            /*margin-bottom: -1px;*/
            padding-bottom: 10px;
        }

        #phead li.active {
            border-bottom: 2px solid deepskyblue;
            color: deepskyblue;;
        }

        .__tab {
            display: none;
        }

        body {
            /*overflow: hidden;*/
        }

        /*#iframe-container{*/
        /*    position: relative;*/
        /*    overflow: hidden;*/
        /*    padding-bottom: 160%;*/
        /*}*/

        /*#iframe{*/
        /*    position: absolute;*/
        /*    top: 0;*/
        /*    left: 0;*/
        /*    width: 100%;*/
        /*    height: 100%;*/
        /*    border: 0;*/
        /*}*/
        .active {
            display: block !important;
        }

        [v-cloak] {
            display: none !important;
        }

        .fa-bell, .fa-envelope {
            cursor: pointer;
        }

        .fa {
            font-size: 18px;
        }

        .new_edit_title {
            width: 383px;
            height: 35px;
        }

        .new_edit_margin_left {
            margin-left: 15px;

        }

        .btn-primary {
            border: 1px solid #0e86fe;
            color: #ffffff;
            background-color: #0e86fe;
            cursor: pointer;
        }

        .btn {
            position: relative;
            padding: 3px 12px;
            margin: 0;
            /* color: #333; */
            /* text-shadow: 0 1px 0 #fff; */
            white-space: nowrap;
            font-family: "Microsoft YaHei", Simsun, Arial, sans-serif;
            /* font-weight: bold; */
            font-size: 13px;
            text-align: center;
            vertical-align: middle;
            -webkit-background-clip: padding;
            -moz-background-clip: padding;
            cursor: default;
            /* background-color: #f3f3f3; */
            border: 1px solid #d9d9d9;
            -webkit-border-radius: 2px;
            -moz-border-radius: 2px;
            border-radius: 2px;
            /* -webkit-box-shadow: none; */
            /* -moz-box-shadow: none; */
            /* box-shadow: none; */
            background-color: #fff;
            cursor: pointer;
        }

        .new_edit_left {
            float: left;
            margin: 0px;
            padding: 0px;
            width: 25%;
            height: 1000px;
            border-right: 1px solid #ddd;
        }

        .new_edit_right {
            width: 74%;
            margin-left: 25%;
            overflow-x: hidden;
            padding: 10px;
            height: 100%;
            background-color: #ffffff;
        }

        .new_edit_left_title_span {
            line-height: 50px;
            font-weight: 900;
            font-weight: bold;
            font-size: 18px;
            color: #0e86fe;
        }

        .new_edit_title_span {
            font-size: 14px;
            font-weight: bold;
            text-align: left;
            line-height: 35px;
        }
    </style>

    <!--    <link rel="stylesheet" href="jquery.webui-popover.min.css">-->
    <!--    <script src="jquery.webui-popover.min.js"></script>-->
    <!--    <script src="right_menu.js"></script>-->
    <!--    <script src="../../../static/vendor/artTemplate/template-web.js"></script>-->
    <script>
        // window.type = getParam("type");
        // window.id = getParam("id");

        // window.Data = null;
        // window.FormBody = null;
    </script>
    <script src="../lib/bpm/bpmn-viewer.js"></script>
    <script src="../lib/layer/layer.js"></script>
    <script src="../lib/laydate/laydate.js"></script>
    <link rel="stylesheet" href="../lib/web-uploader/webuploader.css">
    <script src="../lib/web-uploader/webuploader.min.js"></script>
    <script src="../lib/vue/vue.js"></script>
    <script src="../lib/vue/vue-util.js"></script>
    <script src="../lib/echart/echarts.min.js"></script>
    <script src="../lib/echart/functions.js"></script>
    <link rel="stylesheet" href="../lib/font/css/font-awesome.min.css">
    <script src="../lib/menu/jquery.contextMenu.min.js"></script>
    <script src="../lib/menu/jquery.ui.position.min.js"></script>
    <link rel="stylesheet" href="../lib/menu/jquery.contextMenu.min.css">
</head>
<body>
<div id="app" style="padding: 10px;width:100%; min-width:1024px;" v-cloak>
    <div class="new_edit_left">
        <span class="new_edit_left_title_span">填写该工作的的名称</span>
        <div class="new_edit_title new_edit_margin_left clear"></div>
        名称<br>
        <input type="text" title="名称" v-model="name_id" style="float: none;
    margin-left: 0;border: 1px solid #cccccc;transition: border linear .2s, box-shadow linear .2s;display: inline-block;
    height: 20px; padding: 3px 6px;font-size: 13px;   line-height: 20px;    color: #555555;    border-radius: 4px;
    vertical-align: middle;width: 90%;"/><br>

        <button type="button" class="btn btn-primary" @click="submit()" style="cursor: pointer;">新建并办理</button>
    </div>

    <div class="new_edit_right">
        <div>
            <span class="new_edit_left_title_span">流程说明及表单展示</span><br>
            <span class="new_edit_title_span">流程说明</span>
            <br>
            <span>{{desc}}</span>
        </div>
        <div style="border:1px solid #000;width: 90%;height: 400px;margin-top: 10px;">
            <!--            <ins-canvas :data="data" v-if="data"></ins-canvas>-->
            <div class="canvas" ref="canvas" style="width: 100%;height: 100%;"></div>
        </div>
    </div>

</div>

<DIV class=contextMenu id=myMenu1 style="display: none;">
    <UL>
        <LI id=open style="font-size: 12px;line-height: 20px;vertical-align: middle;"><IMG width="20px" height="20px"
                                                                                           style="margin-top: -3px;margin-right: 5px;"
                                                                                           src="his.png">提交历史
        </LI>
    </UL>
</DIV>


</body>
</html>
<script type="text/html" id="node_temp">
    <select class="form-control input-sm" id="selectCat">
        {{each nodeList value index}}
        <option value="{{value.id}}">{{value.name}}</option>
        {{/each}}
    </select>
</script>
<script>

    window._node = "";
    window.app = new Vue({
        el: "#app",
        data: {
            data: null,
            id: "",
            desc: "",
            name_id: "",
            text: ""

        },
        methods: {
            /**
             * 初始化页面
             */
            load: function () {
                this.id = getParam("id");
                this.text = decodeURIComponent(getParam("text"));
                var text1 = this.text
                document.title = "发布任务";
                var ajax = $.get("/api/bpm/BpmXmlController/one", {
                    _id: this.id,
                });


                var t = this;
                $.when(ajax).then(function (msg) {
                    if (!msg.success) {
                        return layer.msg(msg.errMessage);
                    }

                    t.data = null;
                    t.$nextTick(function () {
                        t.inited = true;
                        t.data = msg.data;
                        if (t.type == "edit") {
                            t.data.deal = true;
                        }
                        this.initCanvas();
                    });
                    t.files = msg.data.files || [];
                    console.log(msg.data.desc + "msg.datamsg.data");
                    t.desc = msg.data.desc != "" ? msg.data.desc : "暂无流程说明"
                    const date = new Date()
                    t.name_id = text1
                        // + "(" + "2" + date.getYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate() +
                        // " " + date.getHours() + ":" + date.getMinutes() + ")"
                });

            },

            initCanvas: function () {
                var canvas = this.$refs.canvas;
                canvas.innerHTML = "";
                var t = this;
                var bpmnViewer = new BpmnJS({
                    container: '.canvas'
                });
                bpmnViewer.importXML(t.data.xml, function (err) {
                    if (err) {
                        return console.error('could not import BPMN 2.0 diagram', err);
                    }
                    // access viewer components
                    var canvas = bpmnViewer.get('canvas');
                    var overlays = bpmnViewer.get('overlays');
                    // add marker
                    $.each(t.data.current || [], function (i, v) {
                        canvas.addMarker(v, 'needs-discussion');
                    });
                })
            },


            /**
             *  任务保存 提交
             */
            submit: function () {
                var idex = layer.load(2);
                $.post("/api/bpm/workflow/createInsNew", JSON.stringify({
                    id: this.id,
                    ext: {name: this.name_id}
                }), function (msg) {
                    layer.close(idex);
                    if (!msg.success) {
                        return layer.msg(msg.errMessage);
                    }
                    window.open("./ins.pub.html?type=deal&id=" + msg.data, "dealtask", "left=100, top=100, width=1000, height=600");
                }, "json")

            },

            getExt: function (name) {
                var i = name.lastIndexOf(".");
                if (i == -1) {
                    return null;
                }
                var ext = name.substring(i + 1);
                return ext.toLocaleLowerCase();
            },
            canPreview: function (name) {
                var ext = this.getExt(name);
                if ({
                    xls: 1,
                    xlsx: 1,
                    doc: 1,
                    docx: 1,
                    ppt: 1,
                    pptx: 1,
                    pdf: 1
                }[ext] == 1) {
                    return true;
                }
                return false
            }
        },
        mounted:

            function () {
                this.load()
            }
    })
    ;

</script>


